import os
import math

import pygame


class ArcticProjectile(pygame.sprite.Sprite):
	"""Base class for ammuntion (Arctic Bullets)"""
	def __init__(self, pos, dest):
		pygame.sprite.Sprite.__init__(self) # Initialize base class.
		spriteFile = os.path.join('data', self.spriteName)
		self.image = pygame.image.load(spriteFile).convert_alpha()
		self.rect = self.image.get_rect()
		self.rect.center = pos
		self.dest = dest
		#self.temperature = -5 # This is object is cool.
		#self.speed = 4
		#self.isPassed = False

	def update(self):
		dx = self.dest[0] - self.rect.center[0]
		dy = self.dest[1] - self.rect.center[1]
		d = math.sqrt(pow(dx, 2) + pow(dy, 2))
		if d > self.speed:
			x = math.floor((self.speed / d) * dx)
			y = math.floor((self.speed / d) * dy)
			self.rect.move_ip(x, y)
		#elif self.isPassed == False:
			#dx = math.floor(dx * 2)
			#dy = math.floor(dy * 2)
			#self.dest = dx + self.rect.center[0], dy + self.rect.center[1]
			#self.isPassed = True
		else:
			self.kill()

	def hit(self, target):
		target.hit(self)
		self.kill()

